/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package cn.net.greenet.policybank.logic;

import cn.net.greenet.common.policy_service.PolicySupport;
import java.util.List;

import com.ambimmort.prserver.bean.RepositoryOperationLogBean;
import net.sf.json.JSONArray;
import net.sf.json.JSONObject;

/**
 * 根据指定的MessageType和MessageNo来获取该策略的所有版本和内容
 *
 * @author liangdelin
 */
public class GetMessageLogs {

    public void getMLogs(String type, String instance, int messageNo) {
        //getMessageLogs(String type, String instance, int messageNo)
        List<RepositoryOperationLogBean> logBeans = PolicySupport.getInstance().getApi().getMessageLogs(type, instance, messageNo);
        JSONArray jsona = new JSONArray();
        for (RepositoryOperationLogBean logBean : logBeans) {
            JSONObject jo = new JSONObject();
            jo.put("id", logBean.getId());
            jo.put("CreateTime", logBean.getCreateTime());
            jo.put("MessageNo", logBean.getSvnFile().getMessageNo());
            jo.put("Content", logBean.getSvnFile().getContent());  //这里需要解析UC
            jsona.add(jo);
        }
    }
}
